package com.boot.netty.client.handler;

import com.boot.netty.commons.codec.marshalling.MarshallCodeFactory;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

import java.util.concurrent.TimeUnit;

public class NettyClientHandler extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new IdleStateHandler(3, 3, 0, TimeUnit.SECONDS))
                .addLast(MarshallCodeFactory.deCoder())
                .addLast(MarshallCodeFactory.enCoder())
                .addLast(new ClientChannelHandlerAdapter());
    }
}
